//
//  LoggerServiceProtocol.swift
//  
//
//  Created by tank on 2023/8/21.
//

import Foundation
import Logging


/// The log level.
///
/// Log levels are ordered by their severity, with `.trace` being the least severe and
/// `.critical` being the most severe.
public enum Level: String, Codable, CaseIterable {
    /// Appropriate for messages that contain information normally of use only when
    /// tracing the execution of a program.
    case trace
    
    /// Appropriate for messages that contain information normally of use only when
    /// debugging a program.
    case debug
    
    /// Appropriate for informational messages.
    case info
    
    /// Appropriate for conditions that are not error conditions, but that may require
    /// special handling.
    case notice
    
    /// Appropriate for messages that are not error conditions, but more severe than
    /// `.notice`.
    case warning
    
    /// Appropriate for error conditions.
    case error
    
    /// Appropriate for critical error conditions that usually require immediate
    /// attention.
    ///
    /// When a `critical` message is logged, the logging backend (`LogHandler`) is free to perform
    /// more heavy-weight operations to capture system state (such as capturing stack traces) to facilitate
    /// debugging.
    case critical
    
    public var loggerLevel: Logger.Level {
        return Logger.Level(rawValue: rawValue) ?? .info
    }
}

public protocol LoggerServiceProtocol: AnyObject {
    func log(level: Level, message: String)
}
